<?php

function i18n_setup()
{
	global $locale;
	session_start();

	$locale_session;

	if(!empty($_REQUEST['locale']))
	{
		$locale_session = $_REQUEST['locale'];
	}
	else if ( !empty($_SESSION['locale']))
	{
		$locale_session = $_SESSION['locale'];
	}
	else
	{
		$locale_session = 'zh_CN';
	}

	$_SESSION['locale'] = $locale_session;
	$locale = $_SESSION['locale'];
}

/**
 * Get the value by the current locale
 * @param unknown_type $values
 * @param unknown_type $key
 * @param unknown_type $connector
 */
function get_value_by_locale($values, $key, $current_locale='', $connector = '_')
{
	if(empty($current_locale))
		$current_locale = 'zh_CN';
	$key_with_locale = $key.$connector.$current_locale;

	return $values->$key_with_locale;
}

function display_boolean_value($value)
{
	if($value)
		return '是';
	else
		return '否';
}

?>